package com.tang.algorithm.array;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/6/4 23:02
 */
public class LeetCode1313 {
    public static void main(String[] args) {
        int[] a = {1,2,3,4};
        decompressRLElist(a);
    }
    public static int[] decompressRLElist(int[] nums) {
        int size=0;
        for (int i = 0; i <nums.length ; i++) {
            if (i%2==0){
                size+=nums[i];
            }
        }
        int[] a = new int[size];

        int count=0;
        for (int i = 0; i <nums.length ; i++) {
            if(i%2==0){
                for (int j = 0; j <nums[i] ; j++) {
                    a[count]=nums[i+1];
                    count++;
                }
            }
        }
        return a;
    }
}
